package com.one.consumer.reserve.model;

import com.one.common.model.bean.BannerBean;
import com.one.common.model.http.NetConstant;
import com.one.common.model.http.base.BaseModel;
import com.one.common.model.http.callback.ObserverOnNextListener;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.view.base.BaseActivity;
import com.one.consumer.common.state.OrderStateCu;
import com.one.consumer.common.state.OrderStateDe;
import com.one.consumer.reserve.model.bean.DEStyleBean;
import com.one.consumer.reserve.model.bean.ReserveIconBean;
import com.one.consumer.reserve.model.bean.TimeBean;
import com.one.consumer.reserve.model.item.AreaItem;
import com.one.consumer.reserve.model.item.CaseItem;
import com.one.consumer.reserve.model.item.CustomItem;
import com.one.consumer.reserve.model.item.CustomProjectItem;
import com.one.consumer.reserve.model.item.ProgramImageItem;
import com.one.consumer.reserve.model.item.ProgramItem;
import com.one.consumer.reserve.model.item.ProjectTypeItem;
import com.one.consumer.reserve.model.item.ReserveItem;

import java.util.ArrayList;
import java.util.Map;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/21 下午9:13
 * description ：
 **/
public class ReserveModel extends BaseModel<ReserveApi> {
    public ReserveModel(BaseActivity mActivity) {
        super(ReserveApi.class, mActivity, NetConstant.APP_HOST_WORKER);
    }


    /**
     * 装修案例展示列表
     */
    public void getCaseListDE(String page, ObserverOnResultListener<ArrayList<CaseItem>> listener) {
        handleOnResultObserver(mApiService.getCaseList(page), listener);
    }

    /**
     * 装修案例详情
     */
    public void getCaseDetailDE(String id, ObserverOnResultListener<CaseItem> listener) {
        handleOnResultObserver(mApiService.getCaseDetail(id), listener);
    }

    /**
     * 定制加配----项目户型方案效果图
     */
    public void getProgramImags(String id, ObserverOnResultListener<ArrayList<ProgramImageItem>> listener) {
        handleOnResultObserver(mApiService.getProgramImags(id), listener);
    }

    /**
     * 获取首页banner
     */
    public void getBanner(ObserverOnResultListener<ArrayList<BannerBean>> listener){
        handleOnResultObserver(mApiService.getBanner("1"), listener);//1:用户 2:师傅
    }

    /**
     * 获取装修样式
     */
    public void getStyles(ObserverOnResultListener<ArrayList<DEStyleBean>> listener){
        handleOnResultObserver(mApiService.getStyles(getParams()), listener);//1:用户 2:师傅
    }

    /**
     * 添加预约，装修，设计
     */
    public void reserve(Map<String, String> params,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.putAll(params);
        handleOnResultObserver(mApiService.reserve(p), listener);
    }

    /**
     * 项目列表
     */
    public void getCutomProjectList(String page, ObserverOnResultListener<ArrayList<CustomProjectItem>> listener) {
        handleOnResultObserver(mApiService.getCutomProjectList(page), listener);
    }

    /**
     * 项目户型列表
     */
    public void getProjectTypeList(String id, ObserverOnResultListener<ArrayList<ProjectTypeItem>> listener) {
        handleOnResultObserver(mApiService.getProjectTypeList(id), listener);
    }

    /**
     * 项目户型方案列表
     */
    public void getProjectProgramList(String id, ObserverOnResultListener<ArrayList<ProgramItem>> listener) {
        handleOnResultObserver(mApiService.getProjectProgramList(id), listener);
    }

    /**
     * 定制装配下单
     */
    public void customOrder(Map<String, String> params,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.putAll(params);
        handleOnResultObserver(mApiService.customOrder(p), listener);
    }


    /**
     * 装修预约订单列表
     */
    public void getReserveList(String page,String type, ObserverOnResultListener<ArrayList<ReserveItem>> listener) {
        Map<String, String> p = getParams();
        p.put("page", page);
        p.put("order_type", type);
        p.put("order_state", OrderStateDe.RESERVE+","+OrderStateCu.CANCLE);
        handleOnResultObserver(mApiService.reserveList(p), listener);
    }

    /**
     * 定制加配预约订单列表
     */
    public void getCustomList(String page, ObserverOnResultListener<ArrayList<CustomItem>> listener) {
        Map<String, String> p = getParams();
        p.put("page", page);
        p.put("order_state", OrderStateCu.RESERVE+","+OrderStateCu.CANCLE);
        handleOnResultObserver(mApiService.customList(p), listener);
    }

    /**
     * 预约订单详情，装修，设计
     */
    public void getReserveDetail(String id, ObserverOnResultListener<ReserveItem> listener) {
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.reserveDetail(p), listener);
    }

    /**
     * 预约订单详情，定制加配
     */
    public void getCustomDetail(String id, ObserverOnResultListener<CustomItem> listener) {
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.customDetail(p), listener);
    }

    /**
     * 报修----服务时间列表
     */
    public void getTimeList(String id, ObserverOnResultListener<ArrayList<TimeBean>> listener) {
        handleOnResultObserver(mApiService.getTimeList(id), listener);
    }

    /**
     * 报修----维修区域
     */
    public void getAreaList(String id, ObserverOnResultListener<ArrayList<AreaItem>> listener) {
        handleOnResultObserver(mApiService.getAreaList(id), listener);
    }


    /**
     * 报修订单-----下单
     */
    public void order(Map<String, String> params,ObserverOnNextListener<Object> listener){
        Map<String, String> p = getParams();
        p.putAll(params);
        handleOnNextObserver(mApiService.order(p), listener);
    }

    /**
     * 获取预约装修的图标
     */
    public void getImg(ObserverOnResultListener<ReserveIconBean> listener){
        handleOnResultObserver(mApiService.getImg(getParams()), listener);
    }

    /**
     * 删除预约单 -- 装修
     */
    public void deleteReserve(String id,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.deleteDe(p), listener);
    }

    /**
     * 取消预约单  -- 装修
     */
    public void cancelReserve(String id,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.cancelDe(p), listener);
    }

    /**
     * 删除预约单 -- 定制
     */
    public void deleteCustom(String id,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.deleteCu(p), listener);
    }

    /**
     * 取消预约单  -- 定制
     */
    public void cancelCustom(String id,ObserverOnResultListener<Object> listener){
        Map<String, String> p = getParams();
        p.put("order_id", id);
        handleOnResultObserver(mApiService.cancelCu(p), listener);
    }


}
